export default {
    // 获取本地时间
    getCurrentTime(){
        let newDate = new Date(),
            dateYear = newDate.getFullYear(),
            dateMonth = newDate.getMonth() + 1,
            dateDay = newDate.getDate(),
            // dateHour = newDate.getHours(),
            // dateMinute = newDate.getMinutes(),
            // dateSecond = newDate.getSeconds(),
            // dateTimeArray = [dateHour,dateMinute,dateSecond],
            dateArray = [dateYear,dateMonth,dateDay];

        dateArray = dateArray.map(val => {
            // return val > 9 ? val : `0${val}`;
            return val;
        })
        // dateTimeArray = dateTimeArray.map(val => {
        //     return val > 9 ? val : `0${val}`;
        // })
        return `${dateArray[0]}年${dateArray[1]}月${dateArray[2]}日`;
    },
    getDateTime(val){
        if(!val) return;
        let newDate = new Date(val),
            dateYear = newDate.getFullYear(),
            dateMonth = newDate.getMonth() + 1,
            dateDay = newDate.getDate(),
            dateHour = newDate.getHours(),
            dateMinute = newDate.getMinutes(),
            dateSecond = newDate.getSeconds(),
            dateTimeArray = [dateHour,dateMinute,dateSecond],
            dateArray = [dateYear,dateMonth,dateDay];

        dateArray = dateArray.map(val => {
            return val > 9 ? val : `0${val}`;
        })
        dateTimeArray = dateTimeArray.map(val => {
            return val > 9 ? val : `0${val}`;
        })
        return `${dateArray.join('-')} ${dateTimeArray.join(':')}`;
    },
    //将数组分割成小数组，每个小数组有size项
    sliceArray(array, size) {
        var result = [];
        for (var x = 0; x < Math.ceil(array.length / size); x++) {
            var start = x * size;
            var end = start + size;
            result.push(array.slice(start, end));
        }
        return result;
    },
}